<?php 
session_start();
$active = 'hometours';
$set = 'blogsystem';
if($_GET['page']==='add')
$set = 'blogsystem';
if(!isset($_SESSION['username']) || !isset($_SESSION['id']))
{
	header("Location: index.php");
	exit();
}
require("../config.php");
require("../db/opendb.php");
if(isset($_POST['submit'])) {
	$sql = "UPDATE PROPERTIES SET bg_type='{$_POST['bg_type']}', bg_color='{$_POST['bg_color']}' WHERE OID='".$_POST["listing_id"]."'";
	mysql_query($sql);
}
$query = "select bg_type, bg_color from PROPERTIES WHERE OID='".$_REQUEST["listing_id"]."'";
$result = mysql_query($query) or die ("SQL Error".mysql_error());
$row=mysql_fetch_assoc($result);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Realivent.com - Edit User account</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">@import "accounts.css";</style>
<link rel="stylesheet" href="css/colorpicker.css" type="text/css" />
<link rel="stylesheet" href="css/layout.css" type="text/css" />

<!--<script type="text/javascript" src="js/jquery-1.5.min.js"></script>-->
<!--<script type="text/javascript" src="js/eye.js"></script>
<script type="text/javascript" src="js/utils.js"></script>
<script type="text/javascript" src="js/layout.js?ver=1.0.2"></script>-->
</head>
<body>
<div id="wrap">
	<?php include('accounts_top_navigation.php'); ?>
	<div id="leftCol" style="text-align:left">
 		 <?php
 		 if(isset($_SESSION['id']) && $row['disp_profile'] != 'No')
 		 {
 		 	include("accounts_left_navigation.php");
 		 }
		 ?>
	</div>	<!-- Left Column -->  
    <div id="mainBody">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="100%" valign="top" align="left"> 
	<div style="margin-left:25px;">
	  <p>&nbsp;</p>
	  <h1>Welcome to Realivent Home Tours</h1>
	  <p>You can configure your home tour and preview it here.</p>
	  <p>&nbsp;</p>
	  <h2><a href="">Step #1</a> Choose a listing from the pull-down menu below.</h2>
	  <p>&nbsp;</p>
	  <p><?php include('change_listing_include.php'); ?></p>
	  <div><br/>
       <p><a href="">Step #2</a> Choose a background color or choose an image to use as the home tour background.</p>
      <br/>
      </div>
      <form method="POST" action="hometours.php">
	  <input type="hidden" value="<?php echo $_REQUEST['listing_id']?>" name="listing_id">
	  <p>
	  <input type="radio" class='bg_selector' name="bg_type" value="c" <?php if($row['bg_type'] == 'c') echo 'checked';?>> Use background color<br>
	  <div id= 'col_selector' style="display:<?php if($row['bg_type'] == 'c') echo 'block'; else echo 'none';?>">
	    <div id="colorSelector"><div style="background-color: <?php if($row['bg_color']) echo $row['bg_color']; else echo 'rgb(191, 255, 0)'?>;"></div></div>
	  	<input type="hidden" name="bg_color" id="bg_color" value="<?php echo $row['bg_color']?>">
	  </div>
	  <input type="radio" class="bg_selector" name="bg_type" value="i" <?php if($row['bg_type'] == 'i') echo 'checked';?>> use one of property image as background (<a href="<?php echo SITE_ROOT_URL?>accounts/edit_photos_listings.php?listing_id=<?php echo $_REQUEST['listing_id']?>">Set background image</a>)
	  </p>
	  <p><input type="submit" value="Save" name="submit"></p>
	  </form>
	  <div><br/>
       <p><a href="">Step #3</a> <strong><a href="/vt/<?php echo $_REQUEST['listing_id']?>" target="_blank" >Preview your home tour</a></strong></p>
       
       
       <h1><br/>
       </h1>
      </div>
     
	</div>
	<BR>
	</td>
  </tr>
</table>
<?php include('../footer.php'); ?>
</body>
<script type="text/javascript" src="js/colorpicker.js"></script>
<script>
jQuery(function() {
	jQuery('.bg_selector').click(function() {
		if(jQuery(this).val() == 'c') jQuery('#col_selector').show(); else jQuery('#col_selector').hide();
	});
	jQuery('#colorSelector').ColorPicker({
		color: '<?php echo $row['bg_color']?>',
		onShow: function (colpkr) {
			jQuery(colpkr).fadeIn(500);
			return false;
		},
		onHide: function (colpkr) {
			jQuery(colpkr).fadeOut(500);
			return false;
		},
		onChange: function (hsb, hex, rgb) {
			jQuery('#bg_color').val('#' + hex);
			jQuery('#colorSelector div').css('backgroundColor', '#' + hex);
		}
	});
});
</script>
</html>